import {View, Text, Button} from 'react-native';
import React from 'react';
import {createDrawerNavigator} from '@react-navigation/drawer';

const Drawer = createDrawerNavigator();

function Home({navigation}) {
  return (
    <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>Home</Text>
      <Button title="open Drawer" onPress={() => navigation.openDrawer()} />
      <Button title="toggle Drawer" onPress={() => navigation.toggleDrawer()} />
    </View>
  );
}

function newScreen({navigation}) {
  return (
    <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>newScreen</Text>
      <Button title="跳转到Home " onPress={() => navigation.navigate('Home')} />
    </View>
  );
}
export default function DrawNavigationCom() {
  return (
    <Drawer.Navigator>
      <Drawer.Screen name="Home" component={Home} />
      <Drawer.Screen name="newScreen" component={newScreen} />
    </Drawer.Navigator>
  );
}
